from PIL import Image, ImageDraw, ImageFont

# 创建画布
img = Image.new('RGB', (600, 300), color='white')
draw = ImageDraw.Draw(img)
font = ImageFont.load_default()

# 绘制最大公约数和最小公倍数的结果
draw.text((10, 10), "最大公约数 (GCD): 6", fill="black", font=font)
draw.text((10, 50), "最小公倍数 (LCM): 36", fill="black", font=font)

# 保存图像
img_path = "gcd_lcm_visualization.png"
img.save(img_path)
print(f"图形已保存为 {img_path}")